
import { Badge, Button, Space } from 'antd';

export const AformConfig = [
    {
        type: "Input",
        lable: "账户",
        placenholder: "请输入用户账户",
        key: "name",
    },
    {
        type: "Input",
        lable: "邮箱",
        placenholder: "请输入联系方式",
        key: "email",
    },
    {
        type: "Select",
        lable: "角色",
        placenholder: "",
        key: "role",
        options: [
            {
                key: "admin",
                lable: "管理员"
            },
            {
                key: "visitor",
                lable: "访客"
            }
        ]
    },
    {
        type: "Select",
        lable: "状态",
        placenholder: "",
        key: "status",
        options: [
            {
                key: "locked",
                lable: "锁定"
            },
            {
                key: "active",
                lable: "可用"
            }
        ]
    },
    {
        type: "Find",
        text: "收搜"
    },
    {
        type: "Reset",
        text: "重置"
    }
]

export const tableColumns = (
    // PassCommrnt: (id: number, flag: boolean) => void,
    // Recomment: (record: object) => void,
    Start:(record:any, status:any)=>void,
    Auth: (record:any, role:any) => void) => {
    return [
        {
            title: '账户',
            dataIndex: 'name',
            key: 'name',
        },
        {
            title: '邮箱',
            dataIndex: 'email',
            key: 'email',
        },
        {
            title: '角色',
            dataIndex: 'role',
            key: 'role',
            render(text: string) {
                return text === "admin" ? "管理员" : "游客"
            }
        },
        {
            title: '状态',
            dataIndex: 'status',
            key: 'status',
            render(text: string) {
                return text === "active" ? <span><Badge status="warning" ></Badge> 锁定</span> : <span><Badge status="success"  ></Badge> 启用</span>
            }
        },
        {
            title: '注册日期',
            dataIndex: 'updateAt',
            key: 'updateAt',
        },
        {
            title: '操作',
            dataIndex: 'action',
            key: 'action',
            render: (_: any, record: any) => {
                // const id=record.id
                console.log(_, record)
                const id = record.id
                return (
                    <Space>
                        <a onClick={() => Start(record, record.status)}>{record.status === "active" ? "启用" : "禁用"}</a>
                        <a onClick={() => Auth(record, record.role)}>{record.role === "visitor" ? "授权" : "解除授权"}</a>
                    </Space>
                )
            }
        }
    ];

}